package com.edu.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @Author:何包蛋
 * @Date :2022/10/26 - 10 - 26 - 16:47
 */
public class MyProcessor implements BeanPostProcessor {

    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
//       if(beanName.equals("myuser")){
//           User u = (User)bean;
//           u.setUsername("lihua");
//       }
        System.out.println("5 执行了 bean后处理器的 前置处理");
       return bean;
    }

    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("8 执行了 bean后处理器的 后置处理");
//        if(beanName.equals("myuser")) {
//            User u = (User) bean;
//            u.setUsername("lihua");
//        }
        return bean;
    }
}
